﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="OdigoImageComboBox.xaml"/>
        <ResourceDictionary Source="OdigoRadar.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <DataTemplate DataType="{x:Type vm:HomePageViewModel}">
        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Panel.Resources>
                <c:CommandExecutor x:Key="executor" Command="{Binding UpdateUserListsCommand}"/>
            </Panel.Resources>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <TextBlock Grid.Row="0" HorizontalAlignment="Center">
                <Hyperlink Command="{Binding GoToTextChatCommand}"><TextBlock Text="{c:LocalizedString s_TextChat}"/></Hyperlink>
            </TextBlock>
            
            <ComboBox x:Name="radarSource" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" SelectedValue="TextChat" Style="{StaticResource ImageComboBoxStyle}">
                <ComboBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type s:String}">
                        <Image x:Name="image" Stretch="None"/>
                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding}" Value="VoiceChat">
                                <Setter TargetName="image" Property="Source" Value="OdigoImages\RadarMode_VoiceChat.png"/>
                                <Setter TargetName="image" Property="ToolTip" Value="{c:LocalizedString s_VoiceChatUsers}"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding}" Value="TextChat">
                                <Setter TargetName="image" Property="Source" Value="OdigoImages\RadarMode_TextChat.png"/>
                                <Setter TargetName="image" Property="ToolTip" Value="{c:LocalizedString s_TextChatUsers}"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding}" Value="Last15">
                                <Setter TargetName="image" Property="Source" Value="OdigoImages\RadarMode_Last15.png"/>
                                <Setter TargetName="image" Property="ToolTip" Value="{c:LocalizedString s_Last15Users}"/>
                            </DataTrigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
                
                <s:String>VoiceChat</s:String>
                <s:String>TextChat</s:String>
                <s:String>Last15</s:String>
            </ComboBox>
            
            <ItemsControl x:Name="radar" Grid.Row="1" Style="{StaticResource RadarStyle}" Margin="2" c:RadarPanel.IsScanning="{Binding Path=IsUpdatingUserLists, Mode=OneWay}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <ContentControl Style="{StaticResource User_RadarItemStyle}">
                            <ContentControl.ContextMenu>
                                <ContextMenu c:Extensions.Items="{Binding Converter={x:Static vm:UserMenuItemsConverter.Default}}" DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}"/>
                            </ContentControl.ContextMenu>
                        </ContentControl>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

            <Button Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Content="{c:LocalizedString s_Go}" Command="{Binding UpdateUserListsCommand}" Style="{StaticResource GoButtonStyle}"/>
        </Grid>

        <DataTemplate.Triggers>
            <Trigger SourceName="radarSource" Property="SelectedValue" Value="VoiceChat">
                <Setter TargetName="radar" Property="ItemsSource" Value="{Binding Path=VoiceChatUsers}"/>
            </Trigger>
            <Trigger SourceName="radarSource" Property="SelectedValue" Value="TextChat">
                <Setter TargetName="radar" Property="ItemsSource" Value="{Binding Path=TextChatUsers}"/>
            </Trigger>
            <Trigger SourceName="radarSource" Property="SelectedValue" Value="Last15">
                <Setter TargetName="radar" Property="ItemsSource" Value="{Binding Path=Last15Users}"/>
            </Trigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>